﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DbType = SqlSugar.DbType;
using MySqlConnector;
using S7Simulate.Config;

namespace S7Simulate.Utils
{
    public class SqlSugarUtil
    {
        /// <summary>
        /// 商川存储过程sqlserver
        /// </summary>
        /// <returns></returns>
        public static SqlSugarClient GetSqlServerSqlClientl()
        {
            var constr = CommonbaseConfig.BaseConfig.SqlserverConnForSc;
            var db = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = constr,
                DbType = DbType.SqlServer,
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute
            }); //默认SystemTable
            return db;
        }
        /// <summary>
        /// 分拣扫描报工专用
        /// </summary>
        /// <returns></returns>
        public static SqlSugarClient GetSqlServerSqlClientl_baogong()
        {
            var constr = CommonbaseConfig.BaseConfig.SqlserverConnForSc;
            var db = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = constr,
                DbType = DbType.SqlServer,
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute
            }); //默认SystemTable
            return db;
        }
        /// <summary>
        /// 下架报工专用
        /// </summary>
        /// <returns></returns>
        public static SqlSugarClient GetSqlServerSqlClientl_Downbaogong()
        {
            var constr = CommonbaseConfig.BaseConfig.SqlserverConnForSc;
            var db = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = constr,
                DbType = DbType.SqlServer,
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute
            }); //默认SystemTable
            return db;
        }

        /// <summary>
        /// 商川中间库sqlserver
        /// </summary>
        /// <returns></returns>
        public static SqlSugarClient GetMidSqlServerSqlClientl()
        {
            var constr = CommonbaseConfig.BaseConfig.SqlserverConnForSc;
            var db = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = constr,
                DbType = DbType.SqlServer,
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute
            }); //默认SystemTable
            return db;
        }
        /// <summary>
        /// 本地数据库
        /// </summary>
        /// <returns></returns>
        public static SqlSugarClient GetLocalMySqlClient()
        {
            var db = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = CommonbaseConfig.BaseConfig.MySqlConn,
                DbType = DbType.MySql,
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute
            }); //默认SystemTable
            return db;
        }
        /// <summary>
        /// 本地中间库供打孔使用
        /// </summary>
        /// <returns></returns>
        public static SqlSugarClient GetMidMysqlClient()
        {
            var db = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = CommonbaseConfig.BaseConfig.MySqlConnForMid,
                DbType = DbType.MySql,
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute
            }); //默认SystemTable
            return db;
        }

    }
}
